package zhai.docking.alipay.runner;


import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import zhai.docking.alipay.constant.LogConstant;
import zhai.docking.alipay.service.base.alipay.api.notify.BaseAlipayApiNotifySer;
import zhai.docking.alipay.util.JSONUtil;
import zhai.docking.alipay.util.StringUtil;

/**
 * @package: zhai.docking.alipay.runner
 * @project-name: zhai-docking-alipay
 * @description: 启动
 * @author: Created by 翟凤玺
 * @create-datetime: 2021-1-21 11:15
 */
@Slf4j
@Component
public class StartupRunner implements CommandLineRunner {

    private static final String RUNNER_NAME = "【服务启动】";
    private static final String METHOD_QUERY = "（加载）";


    @Autowired
    BaseAlipayApiNotifySer baseAlipayApiNotifySer;

    @Override
    public void run(String... args) throws Exception {
        log.info(StringUtil.join(RUNNER_NAME, LogConstant.SERVICE, METHOD_QUERY));
        /**
         * 保证每次服务启动时，调用蚂蚁金服connect方法
         */
        String result = baseAlipayApiNotifySer.alipayMessage();
        log.info(StringUtil.join(RUNNER_NAME, LogConstant.RESULT, METHOD_QUERY, LogConstant.SUCCESS, JSONUtil.toStr(result)));
    }
}
